<?php
namespace app\manage\controller\agent;
use app\manage\controller\Base;

class Api extends Base
{
	/**
	 * 代理分页接口
	 * @return [type] [description]
	 */
	public function agent_rows(){
		$params = $this->request->param();
        
        $perpagenum = isset($params['limit'])?intval($params['limit']):15;
        $perpagenum = $perpagenum>100?100:$perpagenum;
        $page = isset($params['page'])?intval($params['page']):1;
        $page = $page<1?1:$page;

        unset($params['limit']);
        unset($params['page']);
        $where = [];
        if(isset($params['key'])){
            $where= parseWhere($params['key'],true);
        }
        $where['is_agent'] = 1;

        $data = model('member')->getPageDatas($where,$page,$perpagenum);
        $data['code'] = 1;
        return json($data);
	}

	/**
	 * 代理类型查询接口
	 * @return [type] [description]
	 */
	public function agent_type(){
		$params = $this->request->param();
		$id = isset($params['id'])?$params['id']:null;

		$data = model('agent_type')::agentTypeData($id);

		return json($data);
	}

	/**
	 * 代理类型配置查询接口
	 * @return [type] [description]
	 */
	public function agent_type_config(){
		$params = $this->request->param();
		// 代理类型id
		$id = isset($params['id'])?$params['id']:null;
		$data = model('agent_type_level_coin_config')::agentTypeConfig($id);

		return json($data);
	}




	// public function agent_rows(){
	// 	$params = $this->request->param();
	// 	$where = $params;
	// 	unset($where['page']);
	// 	if(!isset($where['is_agent'])){
	// 		$where['is_agent'] = 1;
	// 	}
	// 	$queryStr = $where?'&'.parseQuery($where):'';
	// 	$where = $this -> parseWhere($where);
		

	// 	$query = new MemberQuery;
	// 	$data = $query -> getRows($where,$queryStr,url('agent.show/index'));

	// 	return json($data);
	// }

	


}